Skip to content

fix(pm): bin link - #2458

Merged
elrrrrrrr merged 2 commits into
nextfrom
empty-bin-link
Dec 26, 2025
Merged

fix(pm): bin link#2458
elrrrrrrr merged 2 commits into
nextfrom
empty-bin-link

Conversation

@elrrrrrrr

Copy link
Copy Markdown
Contributor

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @elrrrrrrr, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves an issue where package managers might incorrectly process empty binary paths defined in package metadata. By introducing robust filtering mechanisms, the system now gracefully handles malformed or incomplete 'bin' configurations, ensuring that only valid executable paths are considered. This improves the reliability and stability of package parsing and linking processes.

Highlights

  • Empty Bin Path Filtering: Implemented filtering logic across PackageInfo, BinConfig, and LockPackage to ensure that any empty binary paths specified in package.json or package-lock.json are ignored and not processed.
  • Refactored Bin Parsing: The parsing logic for the 'bin' field in crates/pm/src/model/package.rs was refactored from an if/else structure to a more concise and readable match statement, incorporating the new filtering.
  • Enhanced Test Coverage: New unit tests were added and existing ones extended in crates/ruborist/src/model/package_json.rs and crates/ruborist/src/model/package_lock.rs to specifically validate the correct filtering of empty binary paths in various scenarios.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses an issue with empty bin entries in package.json not being filtered out. The changes are applied consistently across pm, ruborist/model/package_json, and ruborist/model/package_lock to ensure empty binary paths are ignored. The logic is sound, and the inclusion of new tests to verify the fix is a great addition. I have a couple of suggestions to improve the efficiency of the implementation in package.rs and package_json.rs by avoiding intermediate collections.

Comment thread crates/pm/src/model/package.rs Outdated
Comment on lines 119 to 125
pub fn entries(&self, package_name: &str) -> Vec<(String, String)> {
match self {
let entries: Vec<_> = match self {
BinConfig::Single(path) => vec![(package_name.to_string(), path.clone())],
BinConfig::Map(map) => map.iter().map(|(k, v)| (k.clone(), v.clone())).collect(),
}
};
entries.into_iter().filter(|(_, p)| !p.is_empty()).collect()
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While this implementation is correct, it can be made more efficient. Creating an intermediate Vec and then iterating over it again to filter can be avoided. You can perform the filtering directly within the match arms for a cleaner and more performant solution.

    pub fn entries(&self, package_name: &str) -> Vec<(String, String)> {
        match self {
            BinConfig::Single(path) => {
                if !path.is_empty() {
                    vec![(package_name.to_string(), path.clone())]
                } else {
                    vec![]
                }
            }
            BinConfig::Map(map) => map
                .iter()
                .filter(|(_, v)| !v.is_empty())
                .map(|(k, v)| (k.clone(), v.clone()))
                .collect(),
        }
    }

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes issue #2456 by filtering out empty bin paths across the codebase. The implementation ensures that empty string values in the bin field of package.json and package-lock.json files are properly filtered out to prevent linking errors.

  • Adds filtering logic to remove empty bin paths in three modules
  • Includes comprehensive test coverage for the new filtering behavior in two of the three modified files
  • Updates documentation comments to clarify that empty bin paths are filtered out

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
crates/ruborist/src/model/package_lock.rs Adds filtering for empty bin paths in parse_bin_files() method with guard clause for string case and filter for object case; includes comprehensive tests
crates/ruborist/src/model/package_json.rs Adds filtering for empty bin paths in BinConfig::entries() method using a unified filter approach; includes comprehensive tests
crates/pm/src/model/package.rs Refactors bin parsing logic to filter empty bin paths; lacks test coverage for the new filtering behavior

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/pm/src/model/package.rs Outdated
@elrrrrrrr
elrrrrrrr enabled auto-merge (squash) December 26, 2025 06:26
@elrrrrrrr
elrrrrrrr disabled auto-merge December 26, 2025 06:29
@elrrrrrrr
elrrrrrrr merged commit 9b6d67b into next Dec 26, 2025
21 checks passed
@elrrrrrrr
elrrrrrrr deleted the empty-bin-link branch December 26, 2025 06:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants